const http = uni.$u.http

export default {
	//首页
	getHome : (params={})=>{return http.get('/api/index',params)},
	//登录
	authLogin:(params)=>http.post('/api/auth/login',params),
	//退出
	authLoginOut:()=>{http.post('/api/auth/logout')},
	//登录
	register:(params)=>http.post('/api/auth/register',params),
	//个人中心
	userInfo:()=>http.get('/api/user'),
	//修改昵称
	updateUserName:(name)=>http.put('/api/user',name),
	//获取邮箱验证码， 用于更换邮箱
	getEmailCode:(email)=>{http.post('/api/auth/email/code',email)},
	//更换邮箱
	updateEmail:(data)=>{uni.$u.http.patch('/api/auth/email/update',data)},
	//获取手机验证码， 用于绑定手机
	getPhoneCode:(phone)=>{http.post('/api/auth/phone/code',phone)},
	//绑定手机
	updatePhone:(data)=>{http.patch('/api/auth/phone/update',data)},
	//oss token
	ossToken:()=>http.get('/api/auth/oss/token'),
	//更新头像
	updateAvatar:(avatar)=>uni.$u.http.post('/api/user/avatar',avatar),
	//商品详情
	goodsDetail:(id)=>{return http.get('/api/goods/'+id)},
	//收藏商品
	collectGoods:(id)=>http.post('/api/collects/goods/'+id),
	//加入购物车
	addCarts : params=>http.post('/api/carts',params),
	//购物车数量
	cartCount : ()=>http.get('/api/carts'),
	//商品分类
	goodsList:(params={})=>http.get('/api/goods',{params}),
	//购物车列表
	cartList:()=>http.get('/api/carts?include=goods'),
	//数量更改
	cartNum:(id,num)=>http.put('/api/carts/'+id,num),
	cartDel:(id)=>http.delete('/api/carts/'+id),
	//选中购物车商品
	checkedCart:(ids)=>http.patch('/api/carts/checked',ids),
	orderPre:()=>http.get('/api/orders/preview')
	
}